
/**  
 * @Title: TaskExecutorConfig.java
 * @Package com.finfosoft.threads
 * @author FY(543943341@qq.com)
 * @date 2018年1月8日
 * @version V1.0 
 * @Description:
 *    功能说明
 */
    
package com.finfosoft.threads;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @ClassName: TaskExecutorConfig
 * @Description:    多线程与并发编程的配置    实现AsyncConfigurer接口并重写getAsyncExecutor方法，返回ThreadPoolTaskExecutor类，获得线程池taskExecutor
 *    功能描述
 * @author FY(543943341@qq.com)
 * @date 2018年1月8日
 *
 */
@Configuration
@ComponentScan("com.finfosoft.threads")
@EnableAsync //注解开启异步任务支持
public class TaskExecutorConfig implements AsyncConfigurer{

	    
	@Override
	public Executor getAsyncExecutor() {
		
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
		taskExecutor.setCorePoolSize(5);
		taskExecutor.setMaxPoolSize(10);
		taskExecutor.setQueueCapacity(25);
		taskExecutor.initialize();
		return taskExecutor;
	}

	
	    
	@Override
	public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
		// TODO Auto-generated method stub
		return null;
	}

}
